package com.coder.jwt;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

/**
 * @BelongsProject:coder_parent
 * @BelongsPackage:com.coder.jwt
 * @Author:linchong
 * @CreateTime:2019-01-14 09:36
 * @Description:
 */
public class CreateJwt {
    public static void main(String[] args) {
        JwtBuilder jwtBuilder = Jwts.builder()
                .setId("666")
                .setSubject("小红")
                .setIssuedAt(new Date())
                .signWith(SignatureAlgorithm.HS256,"linchong")
                .setExpiration(new Date(new Date().getTime()+60000))
                .claim("role","admin");

        System.out.println(jwtBuilder.compact());
    }
}
